package jxl;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
public class Write {
  public static void main(String[] args) throws IOException {
    String fileName = "C:/Datenbank/out.xlsx";
    //String fileName = "out.xls";
    
    Workbook workbook = new XSSFWorkbook();
    //Workbook workbook = new HSSFWorkbook();
    
    CreationHelper createHelper = workbook.getCreationHelper();
 
    CellStyle headerStyle = workbook.createCellStyle();
    Font headerFont = workbook.createFont();
    headerFont.setFontHeightInPoints((short)10);
    headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    headerStyle.setFont(headerFont);
 
    Sheet sheet = workbook.createSheet();
 
    sheet.setColumnWidth(0, 20 * 256);
    sheet.setColumnWidth(1, 20 * 256);
    sheet.setColumnWidth(2, 20 * 256);
 
    Row row = sheet.createRow(0);
 
    Cell c = row.createCell(0);
    c.setCellStyle(headerStyle);
    c.setCellValue(createHelper.createRichTextString("Email"));
 
    c = row.createCell(1);
    c.setCellStyle(headerStyle);
    c.setCellValue(createHelper.createRichTextString("First Name"));
 
    c = row.createCell(2);
    c.setCellStyle(headerStyle);
    c.setCellValue(createHelper.createRichTextString("Last Name"));
 
    int rowNo = 1;
    row = sheet.createRow(rowNo);
 
    c = row.createCell(0);
    c.setCellValue(createHelper.createRichTextString("test@test.ch"));
 
    c = row.createCell(1);
    c.setCellValue(createHelper.createRichTextString("Ralph"));
 
    c = row.createCell(2);
    c.setCellValue(createHelper.createRichTextString("Schaer"));
 
    FileOutputStream fos = new FileOutputStream(fileName);
    workbook.write(fos);
 
    fos.close();
  }
}